package com.t9.music5;

import com.t9.Note;

import static net.mindview.util.Print.print;

/**
 * Created by xuyiwei on 2018/7/20.
 */

abstract class Instrument {
    private int i; // Storage allocated for each
    public  void play(Note n){
        System.out.println(this+" play() ");
    }
    public  void adjust(){
        System.out.println(this+" adjust() ");
    }
    public abstract String toString();
}

class Wind extends Instrument {

    @Override
    public String toString() {
        return "Wind";
    }
}

class Percussion extends Instrument {

    @Override
    public String toString() {
        return "Percussion";
    }
}

class Stringed extends Instrument {

    @Override
    public String toString() {
        return "Stringed";
    }
}

class Brass extends Wind {
    @Override
    public String toString() {
        return "Brass";
    }
}

class Woodwind extends Wind {
    @Override
    public String toString() {
        return "Woodwind";
    }
}

public class Music5 {
    // Doesn't care about type, so new types
    // added to the system still work right:
    static void tune( Instrument i) {
        // ...
        i.play(Note.MIDDLE_C);
    }
    static void tuneAll( Instrument[] e) {
        for( Instrument i : e)
            tune(i);
    }
    public static void main(String[] args) {
        // Upcasting during addition to the array:
         Instrument[] orchestra = {
                new  Wind(),
                new  Percussion(),
                new  Stringed(),
                new  Brass(),
                new  Woodwind()
        };
        tuneAll(orchestra);
    }
}